<template>
    <div>
        <div id="slider" class="mui-slider">
            <div id="sliderSegmentedControl" class="mui-scroll-wrapper mui-slider-indicator mui-segmented-control mui-segmented-control-inverted">
                <div class="mui-scroll">
                    <a :class="['mui-control-item',item.name=='柯基' ? 'mui-active' : '']"  v-for="item in list" :key="item.ret" @click="getPhotoList(item.ret)">
                        {{item.name}}
                    </a>
                </div>
            </div>
        </div>

        <div>
            <ul class="photoList">
                <li v-for="item in photoList" :key="item.id">
                    <img v-lazy="item.img_url">
                    <div class="info">
                        <h4 class="infoTitle">{{item.title}}</h4>
                        <div class="infoDesc">{{item.detail}}</div>
                    </div>
                </li>
            </ul>
        </div>
    </div>
</template>

<script>
import mui from '../../../lib/MUI/js/mui.min.js'
import { Toast } from 'mint-ui'
export default {
    data() {
        return {
            photoList:[],
            list:[]
        }
    },
    methods: {
        getList(){
            this.axios.get('/api/photoList').then(body=>{
                if (body.data.status === 1) {
                    this.list = body.data.message;
                }else{
                    return Toast("加载失败");
                }
            })
        },
        getPhotoList(ret){
            this.axios.get('/api/photoList/'+ret).then(body=>{
                if (body.data.status === 1) {
                    this.photoList = [];
                    this.photoList = body.data.message;
                }else{
                    return Toast("加载失败")
                }
            })
        }
    },
    created(){
        this.getList();
        this.getPhotoList('dog1');
    },
    mounted() {
        mui('.mui-scroll-wrapper').scroll({
	        deceleration: 0.0005
        });
    }
}
</script>

<style lang="less" scoped>
#slider{
    touch-action: pan-x;
}
.photoList{
    margin: 0;
    padding: 0 5px;
    list-style: none;
    li{
        background-color: #eee;
        text-align: center;
        margin-bottom: 5px;
        position: relative;
        img{
            width: 100%;
            height: 400px;
            vertical-align: middle;
            box-shadow: 0 0 5px #999;
        }
        img[lazy=loading] {
            width: 40px;
            height: 300px;
            margin: auto;
        }
        .info{
            max-height: 82px;
            overflow: hidden;
            color: white;
            position: absolute;
            bottom: 0;
            background-color: rgba(0,0,0,0.4);
            text-align: left;
            .infoDesc{
                font-size: 12px;
            }
            .infoTitle{
                font-size: 14px;
            }
        
        }
    }
}

</style>
